<?php

/*
 * Simple lazy loader
 */

function __autoload($class) {
//	echo "Autoload: ".$class."\n";
	$extensions[] = '.php';
	$extensions[] = '.class.php';
	$extensions[] = '.plugin.php';
	$paths[] = "app/";
	$paths[] = "app/html/core/plugin/";
	$paths[] = "app/style/core/plugin/";
//	$paths[] = "plugins/core/";
//	$paths[] = "plugins/user/";
	$success = array_map(function($path) use ($class,$extensions){
		foreach($extensions as $extension){
			$fullclasspath = $path . str_replace('\\', '/', strtolower($class)) . $extension;
//			echo $fullclasspath."\n";
			if(is_file($fullclasspath)){
				include $fullclasspath;
				return true;
			}
		}
	},$paths);
	if(!in_array(true,$success)){
		throw new Exception("Ressource file $class not found!");
	}
}
?>
